<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>封装练习</title>
</head>
<body>
	<?php
/*
 封装 尽可能得隐藏对象得内部细节，只保留有限的对外接口使之与外部发生联系
 使用private 关键字就实现了对成员得封装

*/
class Person 
  {    private $name;
       private $age;
       private $sex;

   

       }
     function say(){
        echo "my name is".$this->name."my age is".$this->age."my sex is".$this->sex."<br>";

     }
      function eat(){
        echo "这个人在说话"."<br>";
     }
      function run(){
     }	
      function getName(){
    return $this->name;
      }
      function setAge(){
      	if($age>0&&$age<100) 
      	return $this->age=$age;
      else
      	return;
      }
  }
     $p1=new Person("sss",2,"aa");
    // b $p2->name="ca ";
      echo $p1->getName()."<br>";

      $p1->say();
      $p1->setAge(50);

	?>
</body>
</html>